//
//  StudyRecordTypeCell.m
//  TrainTree
//
//  Created by wanghui on 2017/9/22.
//  Copyright © 2017年 YouYeShu. All rights reserved.
//

#import "StudyRecordTypeCell.h"
@interface StudyRecordTypeCell()
@property (weak, nonatomic) IBOutlet UILabel *leftType;
@property (weak, nonatomic) IBOutlet UILabel *rightType;

@property (weak, nonatomic) IBOutlet UILabel *point1;
@property (weak, nonatomic) IBOutlet UILabel *point2;
@property (weak, nonatomic) IBOutlet UILabel *point3;

@property (weak, nonatomic) IBOutlet UILabel *title1;
@property (weak, nonatomic) IBOutlet UILabel *title2;
@property (weak, nonatomic) IBOutlet UILabel *title3;

@property (weak, nonatomic) IBOutlet UILabel *time;
@property (weak, nonatomic) IBOutlet UIImageView *icon;


@end
@implementation StudyRecordTypeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setLabelPoint:self.point1];
    [self setLabelPoint:self.point2];
    [self setLabelPoint:self.point3];
}
- (void)setLabelPoint:(UILabel *)label
{
    label.layer.cornerRadius = 2.0f;
    label.layer.masksToBounds = YES;
    label.layer.borderWidth = 1.0f;
    label.layer.borderColor = rgb(164.0f, 164.0f, 164.0f).CGColor;
}
- (void)configWithDic:(NSDictionary *)dic
{
    if (dic) {
        int iconNum = [dic[@"themeId"] intValue];
//        NSString *themeId = [NSString stringWithFormat:@"%d",iconNum % 6];
//        [self.icon setImage:ImageNamed([KindTurnIcon iconWithId:themeId])  forState:UIControlStateNormal];;
//        self.icon.backgroundColor = [KindTurnIcon iconBgColorWithId:themeId];
        [self.icon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",TrainTreeFileImgURL,dic[@"lessonCover"]]]];
        self.leftType.text = dic[@"themeName"];
        self.rightType.text = [NSString stringWithFormat:@" / %@",dic[@"lessonName"]];
        NSArray *pointArry = dic[@"points"];
        if (pointArry.count >0) {
            self.point1.hidden = NO;
            self.title1.hidden = NO;
            self.title1.text = pointArry[0][@"pointName"];

            if (pointArry.count >1) {
                self.point2.hidden = NO;
                self.title2.hidden = NO;
                self.title2.text = pointArry[1][@"pointName"];

                if (pointArry.count >2) {
                    self.point3.hidden = NO;
                    self.title3.text = pointArry[2][@"pointName"];
                    self.title3.hidden = NO;
                }else{
                    self.point3.hidden = YES;
                    self.title3.hidden = YES;
                }
            }else{
                self.point2.hidden = YES;
                self.point3.hidden = YES;

                self.title2.hidden = YES;
                self.title3.hidden = YES;
            }
        }else{
            self.point1.hidden = YES;
            self.point2.hidden = YES;
            self.point3.hidden = YES;

            self.title1.hidden = YES;
            self.title2.hidden = YES;
            self.title3.hidden = YES;
        }
    }

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
